package com.gitee.ywj1352.design.masterWorker.demo;

import com.gitee.ywj1352.design.masterWorker.Master;
import com.gitee.ywj1352.design.masterWorker.MyWorker;
import com.gitee.ywj1352.design.masterWorker.Task;

/**
 * @author: yangwenjie.a
 * @date: 2021/6/22 10:46
 * @description:
 */
public class Main {

    public static void main(String[] args) {
        MyWorker myWorker = new MyWorker();
        Master master = new Master(myWorker, 5);

        for (int i = 0; i < 100; i++) {
            Task task = new Task();
            task.setId((long)i);
            task.setTaskName("task_name_" + i);
            task.setTaskId(100 + i);
            master.submit(task);
        }
        master.execute();

        try {
            Thread.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        int result = master.getResult();

        System.out.println("结束的 "  + result);

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
